//
//  WebPageViewController.m
//  Auction
//
//  Created by Gary on 15/10/12.
//  Copyright © 2015年 Lebo. All rights reserved.
//

#import "WebPageViewController.h"

@interface WebPageViewController () <UIWebViewDelegate, NetworkFailDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation WebPageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self defaultNavigationLeftBar];
    LogInfo(@"load url: %@", _webPageUrl);
    [_webView loadRequest:[NSURLRequest requestWithURL:_webPageUrl]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)pageBack {
    if (_webView.canGoBack) {
        [_webView goBack];
    } else {
        [super pageBack];
    }
}

#pragma mark - UIWebViewDelegate

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [_baseComponent handleNetworkRequestFailed:error];    
}

#pragma mark - NetworkFailDelegate

- (void)retryNetworkRequest {
    [_webView loadRequest:[NSURLRequest requestWithURL:_webPageUrl]];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
